package com.ssoclient.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

/**
 * @author 11900
 * @version V1.0
 * @Title: ${FILE_NAME}
 * @Package com.sso.utils
 * @Description: TODO
 * @date 2020/4/27 12:32
 */
public class HttpClient {
    private static final OkHttpClient CLIENT = new OkHttpClient();

    public static JSONObject get(String url,String token)throws Exception{
        //设置消息头
        Request.Builder builder = new Request.Builder();
        builder.addHeader("Authorization",token);
        builder.url(url);
        Request request = builder.build();
        Response response = CLIENT.newCall(request).execute();
        return JSON.parseObject(response.body().string());
    }
}
